unit SERVER;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ScktComp, ADODB, Menus, JvComponentBase, JvTrayIcon, DB,
  StdCtrls, ExtCtrls;

type
  TSERVIDOR = class(TForm)
    DataSource1: TDataSource;
    RadioGroup1: TRadioGroup;
    RadioGroup2: TRadioGroup;
    Table1: TADOTable;
    Table1SEQUENCIA: TIntegerField;
    Table1ONLINE: TIntegerField;
    Table1CONECTADO: TStringField;
    Table1NOME: TStringField;
    ADOQuery1: TADOQuery;
    Table1IP: TStringField;
    RadioGroup3: TRadioGroup;
    Table1modulo: TStringField;
    Timer1: TTimer;
    procedure Restaurar1Click(Sender: TObject);
    procedure Minimizar1Click(Sender: TObject);
    procedure RxTrayIcon1DblClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormShow(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SERVIDOR: TSERVIDOR;
  x: integer;

implementation
uses dm;

{$R *.dfm}

procedure TSERVIDOR.Restaurar1Click(Sender: TObject);
begin
servidor.Show;
end;

procedure TSERVIDOR.Minimizar1Click(Sender: TObject);
begin
servidor.Hide;
end;

procedure TSERVIDOR.RxTrayIcon1DblClick(Sender: TObject);
begin
servidor.Show;
end;

procedure TSERVIDOR.FormClose(Sender: TObject; var Action: TCloseAction);
begin
base.LEDWIN.Connected:= false;
base.LED.Connected:= false;
base.sistema.Connected:= false;
base.relacao.Connected:= false;
base.ecf.Connected:= false;
action:= cafree;
end;

procedure TSERVIDOR.FormShow(Sender: TObject);
begin

radiogroup1.Items.Clear;
radiogroup2.Items.Clear;
radiogroup3.Items.Clear;

 table1.active:= false;
table1.active:= true;



table1.first;
while not table1.eof do
begin
if table1online.value = 1 then
begin
radiogroup1.items.add(table1nome.value);
end
else
begin
radiogroup2.items.add(table1nome.value);
end;

if table1modulo.Value <> 'FECHAR' then
begin
radiogroup3.items.add(table1nome.value+': '+table1modulo.Value);
end;

table1.Next;
end;

end;

procedure TSERVIDOR.Timer1Timer(Sender: TObject);
begin
radiogroup1.Items.Clear;
radiogroup2.Items.Clear;
radiogroup3.Items.Clear;


table1.active:= false;
table1.active:= true;



table1.first;
while not table1.eof do
begin
if table1online.value = 1 then
begin
radiogroup1.items.add(table1nome.value);
end
else
begin
radiogroup2.items.add(table1nome.value);
end;

if table1modulo.Value <> 'FECHAR' then
begin
radiogroup3.items.add(table1nome.value+': '+table1modulo.Value);
end;

table1.Next;
end;
end;

end.
